// yb_mingpian/pages/paycontent/userorder/index.js

var app = getApp(),
  api = app.requirejs("api/index"),
  core = app.requirejs("core");

Page({

  data: {
    list: [],
    page: 1,
    end:false,
  },

  onLoad: function (options) {
    var that = this,
      e = {};
    core.get("paycontent/likes", {
      uid: app.getCache("userinfo").uid,
      page: that.data.page
    }, function (t) {
      if (t.code == 1) {
        if (t.info.length > 0) {
          if (that.data.page == 1) {
            e.list = t.info;
          } else {
            e.list = that.data.list.concat(t.info);
          }
          e.page = that.data.page + 1;
          that.setData(e);

          if (t.info.length < 10) {
            that.setData({
              end: true
            });
          }
        } else {
          that.setData({
            end:true
          });
        }
      } else {
        core.alert(t.msg)
      }
    }, true)

  },

  onReady: function () {

  },

  onShow: function () {

  },

  onHide: function () {

  },

  onUnload: function () {

  },

  onPullDownRefresh: function () {

  },

  onReachBottom: function () {
    if (!this.data.end) {
      this.onLoad();
    }
  },

  // onShareAppMessage: function () {
  //
  // }
})